/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dotecon.chapter1;

import java.io.File;
import java.util.Arrays;

/**
 *
 * @author lukas
 */
public class Excercise2 {

    public static void main(final String[] args) {
        Arrays.asList(new String[] {
            "/Users/lukas/"
        }).stream()
                .map(Lambda::new)
//                .map(MethodRef::new)
                .forEach(Print::print);
    }
}

class Lambda implements Print {
    private final File[] files;

    public Lambda(String path) {
        files = new File(path).listFiles(f -> f.isDirectory());
    }
    
    @Override
    public void print() {
        for(File file : files) {
            System.out.println(file.getAbsolutePath());
        }
    }
}

class MethodRef implements Print {
    private final File[] files;

    public MethodRef(String path) {
        files = new File(path)
                .listFiles(File::isDirectory);
    }
    
    @Override
    public void print() {
        for(File file : files) {
            System.out.println(file.getAbsolutePath());
        }
    }
}


interface Print {
    void print();
}